package com.cin.cma.common.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

/**
 * @Author：wubo
 * @Date：2024/7/29 下午2:56
 */
@Getter
public enum SeatStatusEnum {
    SOLD("SOLD", "已售"),
    UNSOLD("UNSOLD", "可售"),
    LOCK("LOCK", "已锁定"),
    BOOKED("BOOKED", "已预订"),
    UNAVAILABLE("UNAVAILABLE", "不可用"),
    ;
    private String code;
    private String name;

    SeatStatusEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据影厅损坏状态构建枚举
     *
     * @param damage
     * @return
     */
    public static SeatStatusEnum buildSeatStatusEnum(String damage) {
        if (StrUtil.isBlank(damage)) {
            return UNAVAILABLE;
        }
        switch (damage) {
            case "damaged":
            case "Y":
                return UNAVAILABLE;
            case "N":
                return UNSOLD;
            case "locked":
                return LOCK;
            case "booked":
                return BOOKED;
            case "selled":
                return SOLD;
            default:
                return UNAVAILABLE;
        }
    }
}
